Skip to content

remove unused imports from generated code#26

Merged
filiphr merged 1 commit into
mapstruct:mainfrom
hduelme:remove-unused-imports-from-generated-code
Jun 2, 2026
Merged

remove unused imports from generated code#26
filiphr merged 1 commit into
mapstruct:mainfrom
hduelme:remove-unused-imports-from-generated-code

Conversation

@hduelme
Copy link
Copy Markdown
Collaborator

@hduelme hduelme commented Mar 17, 2026

This PR removes unused imports and simplifies conditional imports in the template.
Changes

  • Removed the following unused imports:
    • java.util.ArrayList;
    • javax.lang.model.element.ElementKind
    • javax.lang.model.element.VariableElement
    • javax.lang.model.util.AbstractAnnotationValueVisitor8
  • he following imports are only required when gemValueInfos contains values. Instead of always including them, they are now conditionally added via an if statement in the FTL template:
    • java.util.HashMap
    • java.util.List
    • java.util.Map
    • javax.lang.model.element.AnnotationValue
    • javax.lang.model.element.ExecutableElement
    • javax.lang.model.type.TypeMirror
    • javax.lang.model.util.ElementFilter;
    • org.mapstruct.tools.gem.GemValue
  • javax.lang.model.type.TypeMirror is already imported elsewhere and has therefore been excluded from the manual import list.

@hduelme hduelme force-pushed the remove-unused-imports-from-generated-code branch from 7592d1e to 3715a39 Compare May 31, 2026 15:41
Copy link
Copy Markdown
Member

@filiphr filiphr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly OK @hduelme, I only have one question about one of the changes

@filiphr filiphr merged commit ebc50ea into mapstruct:main Jun 2, 2026
5 checks passed
@filiphr filiphr added this to the 1.0.0.Alpha4 milestone Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants